package com.youlu.campus.base.base;

import org.apache.commons.lang3.StringUtils;

/**
 * 内容类型枚举
 * @author: YangJ
 * @date: 2020/11/24 18:55
 */
public enum ContentTypeEnum {

    /**
     * DK打卡 DT动态、PL评论、WZ文章、SP商品
     */
    DK("DK", "打卡"),

    DT("DT", "动态"),

    PL("PL", "评论"),

    WZ("WZ", "文章"),

    HT("HT", "话题"),

    SP("SP", "商品");

    private String code;
    private String desc;

    ContentTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 通过值获得名称
     */
    public static String getName(String code) {
        if (StringUtils.isNotBlank(code)) {
            for (ContentTypeEnum typeEnum : ContentTypeEnum.values()) {
                if (typeEnum.getCode().equals(code)) {
                    return typeEnum.getDesc();
                }
            }
        }
        return "";
    }
}
